import Vue from 'vue';

import 'normalize.css/normalize.css'; // A modern alternative to CSS resets

global.ENVIR = 'login';

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// import locale from 'element-ui/lib/locale/lang/en'; // lang i18n
import i18n from '@/lib/lang/index';

import '@/styles/index.scss'; // 公共样式
import '@/styles/spacing.scss'; // gl的公共样式
import '@/assets/iconfont/iconfont.css';
// import '@/lib/oidc';

import App from './App';
import store from '@/extend/store';
import router from '@/extend/router/login/index';
import * as filters from '@/lib/filter'; // 全局过滤器

import '@/assets/icons/index'; // icon
import { translateByCode } from '@/lib/getTransData';

import { initBaidu } from '../baidu.js';

// 百度统计
if (process.env.VUE_APP_ISUSE_BDTJ) {
  initBaidu();
}

// 全局插件
import Login from '@/plugin/Login';
Vue.use(Login);
import ForgetPassword from '@/plugin/ForgetPassword';
Vue.use(ForgetPassword);
import Register from '@/plugin/Register';
Vue.use(Register);

// 设置全局函数

store.dispatch('app/setTitle', translateByCode(process.env.VUE_APP_TITLE_LOGIN));

// 兼容性解决
if (!window.location.origin) {
  window.location.origin =
    window.location.protocol +
    '//' +
    window.location.hostname +
    (window.location.port ? ':' + window.location.port : '');
}

// 设置elementUi语言
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
});

// 注册全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});

Vue.config.productionTip = false;

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
});
